<%@ page import="databeans.*"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="helper.Balance"%>
<jsp:include page="../common/header.jsp" />

<title>Carnegie Financial Services - View Account</title>
</head>
<body>
	<div id="container">
    	<div id="header">
        	<h2>Carnegie Financial Services</h2>
    		<jsp:include page="../common/top-menu.jsp" />
      </div>
        <div id="wrapper">
            <div id="content">
            	<div id="box">
	            	<h3>Account Info</h3>
	            	<jsp:include page="../common/messages.jsp"/>
	            	<div class="acc-info">
                		<table>
							<tbody>
								<tr>
									<td class="bold">Name</td>
									<td>
										<%=request.getAttribute("name")%>
									</td>
								</tr>
								<tr>
									<td class="bold">Email</td>
									<td>
										<%=request.getAttribute("email") %>
									</td>
								</tr>
								<tr>
									<td class="bold">Address</td>
									<td>
										<%=request.getAttribute("address")%>
									</td>
								</tr>
								<tr>
									<td class="bold">Cash Balance</td>
									<td>
										<%="$" + request.getAttribute("cashBalance")%>
									</td>
								</tr>
								<tr>
									<td class="bold">Cash Available</td>
									<td>
										<%="$" + request.getAttribute("availableCash")%>
									</td>
								</tr>
<% 
String lastTradingDate = (String)request.getAttribute("lastTradingDate");
String lastSubmissionDate = (String)request.getAttribute("lastSubmissionDate"); 
if(lastTradingDate!=null){
%>
								<tr>
									<td class="bold">Last Trading Date</td>
									<td>
										<%=request.getAttribute("lastTradingDate")%>
									</td>
								</tr>
<% 
}else{
%>
								<tr>
									<td><b></>Last Submission Date</b><br/>(No transaction has been executed)</td>
									<td>
										<%=request.getAttribute("lastSubmissionDate")%>
									</td>
								</tr>
		
<%} %>						
								<tr>
									<td class="bold">Shares Owned</td>
									<td>
										<ul>
										<%
											Position[] positions = (Position[])request.getAttribute("positions");
										    ArrayList<Long> values = (ArrayList<Long>)request.getAttribute("values");
										    ArrayList<String> fundNames = (ArrayList<String>)request.getAttribute("fundNames");
											for(int i=0; i<positions.length; i++){
										%>
											<li class="fund"><h3><a href="#" title="View Fund Info"><%=fundNames.get(i)%></a></h3>
												<ul>
													<li><b>Shares:</b> <%=helper.Formatter.prepShareToView(positions[i].getShares())%></li>
													<li><%  
													     if (values.get(i).doubleValue()==0.00){ 
														%>
													    Transaction is still pending
														<% }else{%>
														<b>Total Value:</b> $<%=helper.Formatter.prepCashToView(values.get(i))%>
														<% } %>
													</li>
												</ul>
											</li>
										<% } %>
										</ul>
									</td>
								</tr>
							</tbody>
						</table>
                	</div>
	            </div>
            </div>
            
            <jsp:include page="../common/sidebar.jsp" />
      </div>
        <jsp:include page="../common/footer.jsp" />
</div>
</body>
</html>

